Bug 96431 – Can't cut and paste / DND within invisible entry
authorMatthias Clasen <mclasen@redhat.com>
Fri, 3 Oct 2008 02:01:58 +0000 (02:01 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Fri, 3 Oct 2008 02:01:58 +0000 (02:01 +0000)
2008-10-02  Matthias Clasen <mclasen@redhat.com>

        Bug 96431 – Can't cut and paste / DND within invisible entry

        * gtk/gtkentry.c: Disable cut, copy and drag out of an invisible
        entry. Proposed by Owen Taylor

svn path=/trunk/; revision=21582

ChangeLog
gtk/gtkentry.c

index 1db7dd605dd327caf10e262e1986e69bb6efec88..e4c483a63e423e79736f162ce1cc0c2005f2f6cc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-10-02  Matthias Clasen <mclasen@redhat.com>
+
+       Bug 96431 – Can't cut and paste / DND within invisible entry
+
+       * gtk/gtkentry.c: Disable cut, copy and drag out of an invisible
+       entry. Proposed by Owen Taylor
+
 2008-10-02  Matthias Clasen <mclasen@redhat.com>
 
        Bug 530575 – GtkEntry with invisible chars has a confused cursor in
index cf510a318d05b855b355286c91e320e4ff3cca9b..e3e06cefa9a850cbe4ee8fe537aab14e21d9da17 100644 (file)
@@ -2082,7 +2082,8 @@ gtk_entry_motion_notify (GtkWidget      *widget,
 
   if (entry->in_drag)
     {
-      if (gtk_drag_check_threshold (widget,
+      if (entry->visible &&
+          gtk_drag_check_threshold (widget,
                                     entry->drag_start_x, entry->drag_start_y,
                                     event->x + entry->scroll_offset, event->y))
         {
@@ -2094,11 +2095,8 @@ gtk_entry_motion_notify (GtkWidget      *widget,
 
           gtk_target_list_add_text_targets (target_list, 0);
 
-          if (entry->visible)
-            {
-              text = _gtk_entry_get_selected_text (entry);
-              pixmap = _gtk_text_util_create_drag_icon (widget, text, -1);
-            }
+          text = _gtk_entry_get_selected_text (entry);
+          pixmap = _gtk_text_util_create_drag_icon (widget, text, -1);
 
           context = gtk_drag_begin (widget, target_list, actions,
                                     entry->button, (GdkEvent *)event);
@@ -3127,6 +3125,12 @@ gtk_entry_copy_clipboard (GtkEntry *entry)
 
   if (gtk_editable_get_selection_bounds (editable, &start, &end))
     {
+      if (!entry->visible)
+        {
+          gtk_widget_error_bell (GTK_WIDGET (entry));
+          return;
+        }
+
       gchar *str = gtk_entry_get_public_chars (entry, start, end);
       gtk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (entry),
                                                        GDK_SELECTION_CLIPBOARD),
@@ -3141,6 +3145,12 @@ gtk_entry_cut_clipboard (GtkEntry *entry)
   GtkEditable *editable = GTK_EDITABLE (entry);
   gint start, end;
 
+  if (!entry->visible)
+    {
+      gtk_widget_error_bell (GTK_WIDGET (entry));
+      return;
+    }
+
   gtk_entry_copy_clipboard (entry);
 
   if (entry->editable)
@@ -5480,9 +5490,9 @@ popup_targets_received (GtkClipboard     *clipboard,
                                 popup_menu_detach);
       
       append_action_signal (entry, entry->popup_menu, GTK_STOCK_CUT, "cut-clipboard",
-                           entry->editable && entry->current_pos != entry->selection_bound);
+                           entry->editable && entry->visible && entry->current_pos != entry->selection_bound);
       append_action_signal (entry, entry->popup_menu, GTK_STOCK_COPY, "copy-clipboard",
-                           entry->current_pos != entry->selection_bound);
+                           entry->visible && entry->current_pos != entry->selection_bound);
       append_action_signal (entry, entry->popup_menu, GTK_STOCK_PASTE, "paste-clipboard",
                            entry->editable && clipboard_contains_text);